from tools.listNode import listToNode, nodeToList


def swapPairs(head):
    if head == None or head.next == None:
        return head
    nxt = head.next
    head.next = swapPairs(head.next.next)
    nxt.next = head
    return nxt


head = listToNode([1, 2, 3, 4])
print(nodeToList(swapPairs(head)))  # [2, 1, 4, 3]
